package com.itheima.controller;

import com.itheima.config.PersonProperties;
import com.itheima.service.UserService;
import com.itheima.user.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping(value = "/user")
//@RefreshScope  //刷新配置
public class UserController {

    @Autowired
    private UserService userService;

    //@Value("${person.name}")
    //private String name;

    @Autowired
    private PersonProperties person;
    /***
     * 根据id查询用户详情
     */
    @GetMapping(value = "/{id}")
    public User one(@PathVariable(value = "id") Long id){
        return userService.findById(id);
    }

    @GetMapping("/test")
    public String test(@RequestHeader("name")String name){
        return "你好："+person.getName()+"=="+person.getAge()+"------>"+name;
    }
}
